<template>
  <div class="body">
    <div class="topp">
      <div class="title">
        <van-tabs line-height="2" line-width="20">
          <van-tab title="推荐"></van-tab>
          <van-tab title="最新">最新</van-tab>
        </van-tabs>
        <div></div>
      </div>
      <img class="img" src="../assets/mj.png" />
    </div>
    <Listitem :list="list"></Listitem>
  </div>
</template>

<script>
import Listitem from "@/components/Listitem.vue";
import axios from "axios";

export default {
  name: "HmArticle",
  data() {
    return {
      list: [],
    };
  },
  created() {
    //这里请求 但是可能需要封装一下函数 直接调用函数即可
    this.getList();
  },
  methods: {
    async getList() {
      const res = await axios({
        url: "http://interview-api-t.itheima.net/h5/interview/query",
        params: { current: 1, pageSize: 10 },

        headers: {
          Authorization: `Bearer ${localStorage.getItem("token")}`,
        },
      });
      console.log(res.data);
      this.list = res.data.data.rows;
    },
  },
  components: {
    Listitem,
  },
};
</script>

<style lang="less" scoped>
.body {
  height: 607px;
  .topp {
    display: flex;
    justify-content: space-between;
    .img {
      width: 22%;
      height: 35px;
      //图片比例不变
    }
    .title {
      width: 30%;
    }
  }
}
</style>
